/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MapaDainf.java
 *
 * Created on 09/10/2011, 11:57:36
 */
package projetointegrado;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;

/**
 *
 * @author Thor
 */
public class MapaUtfprBlocos extends javax.swing.JPanel {
    @Override
    public void paintComponent(Graphics g) {
        Image imagem = new ImageIcon("src/Imagens/mapa.png").getImage();
        g.drawImage(imagem, 0, 0, this);
    }
    public MapaUtfprBlocos() {
        initComponents();
        
        
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBox1 = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setMinimumSize(new java.awt.Dimension(830, 600));
        setPreferredSize(new java.awt.Dimension(830, 600));

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Bloco B", "Bloco E" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jLabel1.setText("Escolha o bloco que deseja:");

        jButton1.setText("Ir !");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(687, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(410, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addGap(119, 119, 119))
        );
    }// </editor-fold>//GEN-END:initComponents

private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jComboBox1ActionPerformed

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
 String s= jComboBox1.getSelectedItem().toString();
  //if(s.equals("Bloco E")){
ProjetoIntegrado.sound.stopMidi();

      if(Flag.desenhatela == null){
        JanelaJogo jj = new JanelaJogo(s);  
        Flag.irParaMapa = false;  
        ProjetoIntegrado.janelaPrincipal.add(jj);  
        jj.setVisible(true);  
        jj.setBloco(s);  
        ProjetoIntegrado.mb.setVisible(false);
        jj.repaint();
        jj.requestFocus();
        DesenhaTela dt = jj.criaDesenhaTela();
        Flag.desenhatela = dt;
        ProjetoIntegrado.pld.setVida(jj.player.getHpAtual());
        ProjetoIntegrado.pld.setMana(jj.player.getManaAtual());
        if(s.equals("Bloco B")){
            jj.player.setPosX(400);
        }
        if(s.equals("Bloco E")){
            jj.player.setPosY(530);
            jj.player.setPosX(20);
        } 
      }
      else{
        ProjetoIntegrado.sound.stopMidi();  
        Flag.pararThread = true;
        Flag.andar1BlocoE = false;
        JanelaJogo jj = new JanelaJogo(s);  
        Flag.irParaMapa = false;  
        ProjetoIntegrado.janelaPrincipal.add(jj);  
        jj.setVisible(true);  
        jj.setBloco(s);  
        ProjetoIntegrado.mb.setVisible(false);
        jj.repaint();
        jj.requestFocus();
        DesenhaTela dt = jj.criaDesenhaTela();
        Flag.desenhatela = dt;
        ProjetoIntegrado.pld.setVida(jj.player.getHpAtual());
        ProjetoIntegrado.pld.setMana(jj.player.getManaAtual());
        if(s.equals("Bloco B")){
            jj.player.setPosX(400);
        }
        if(s.equals("Bloco E")){
            jj.player.setPosY(530);
            jj.player.setPosX(20);
        } 
      }
      
     
    
      
      
      
      
 //}
}//GEN-LAST:event_jButton1MouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
}
